from django.shortcuts import render, render_to_response, redirect

from django.http import HttpResponse
from django.template import RequestContext, loader

from django.core import serializers
from django.http import Http404

import json as json2

def template( view ):
	def response( *args, **kwargs ):		

		request, result = view( *args, **kwargs )

		t = loader.get_template( result[ 'template' ] )
		c = RequestContext( request, result[ 'out' ] )

		return HttpResponse(	t.render(c),
        						content_type = 'text/html' )	

	return response

def json( view ):
	def response( *args, **kwargs ):
		request, data = view( *args, **kwargs )

		return HttpResponse(	json2.dumps( data ),
								content_type = 'application/json' )

	return response

	     